﻿using AppService.IService.Sys_statistics;
using Autofac;
using Domain.Entity.System_operation;
using Domain.Entity.System_Ordermanagement;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebAPI.Controllers.Sys_statistics
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Order_statisticsController : ControllerBase
    {
        public Order_statisticsController(IOrder_statisticsService order_StatisticsService)
        {
            Order_StatisticsService = order_StatisticsService;
        }

        public IOrder_statisticsService Order_StatisticsService { get; set; }

        /// <summary>
        /// 查询订单表创建时间的年份
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<string> GetOrder_time_year()
        {
            return Order_StatisticsService.GetOrder_time_year();
        }

        /// <summary>
        /// 根据年份查询数据条数
        /// </summary>
        /// <param name="year"></param>
        /// <returns></returns>
        [HttpGet("{year}")]
        public List<Order_time> Get_time_sum(string year)
        {
            return Order_StatisticsService.GetOreder_time_sum(year);
        }

        /// <summary>
        /// 查询司机业绩统计报表数据的数量
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetOrder_Count()
        {
            return Order_StatisticsService.Count();
        }

        /// <summary>
        /// 查询已完成的运单
        /// </summary>
        /// <returns></returns>
        [HttpGet("{currentPage},{PageSize}")]
        public List<Driver_statistics> GetDriver_Statistics(int currentPage, int PageSize)
        {
            return Order_StatisticsService.GetDriver_Statistics(currentPage, PageSize);
        }

        /// <summary>
        /// 查询运单是按时完成的数量
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<Driver_statistics> GetWb_ment()
        {
            return Order_StatisticsService.GetWb_ment();
        }

        /// <summary>
        /// 查询运单的异常数量
        /// </summary>
        /// <returns></returns>
        [HttpGet("{Dv_id}")]
        public List<Driver_statistics> GetException_log(int Dv_id)
        {
            return Order_StatisticsService.GetException_log(Dv_id);
        }

        /// <summary>
        /// 根据司机id查询运单数据
        /// </summary>
        /// <param name="Dv_id"></param>
        /// <returns></returns>
        [HttpGet("{Dv_id}")]
        public List<Wb_meter> GetWb_Meters(int Dv_id)
        {
            return Order_StatisticsService.GetWb_Meters(Dv_id);
        }

        /// <summary>
        /// 根据创建时间查询司机统计报表数据
        /// </summary>
        /// <returns></returns>
        [HttpGet("{currentPage},{PageSize}")]
        public List<Driver_statistics> GetDriver_Statistics2(string Create_time, int currentPage, int PageSize)
        {
            return Order_StatisticsService.GetDriver_Statistics2(Create_time, currentPage, PageSize);
        }

        /// <summary>
        /// 查询司机统计报表数据
        /// </summary>
        /// <returns></returns>
        [HttpGet("{currentPage},{PageSize}")]
        public List<Driver_statistics> GetDriver_Statistics3(int currentPage, int PageSize)
        {
            return Order_StatisticsService.GetDriver_Statistics3(currentPage, PageSize);
        }

        /// <summary>
        /// 根据创建时间查询司机统计报表数据数量
        /// </summary>
        /// <returns></returns>
        [HttpGet("{Create_time}")]
        public int GetOrder_Count(string Create_time)
        {
            return Order_StatisticsService.Count2(Create_time);
        }

        /// <summary>
        /// 根据时间年份查询运单数量
        /// </summary>
        /// <param name="Year"></param>
        /// <returns></returns>
        [HttpGet("{Year}")]
        public List<Order_time> GetWb_meter(string Year)
        {
            return Order_StatisticsService.GetWb_Meters(Year);
        }

        /// <summary>
        /// 查询订单表条数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int Count3()
        {
            return Order_StatisticsService.Count3();
        }

        /// <summary>
        /// 待调度的订单数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetOrders_count()
        {
            return Order_StatisticsService.GetOrders_count();
        }

        /// <summary>
        /// 待签收的订单数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetOrders_count2()
        {
            return Order_StatisticsService.GetOrders_count2();
        }

        /// <summary>
        /// 待发车的运单数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetWb_meter_count()
        {
            return Order_StatisticsService.GetWb_meter_count();
        }

        /// <summary>
        /// 运输中的运单数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetWb_meter_count2()
        {
            return Order_StatisticsService.GetWb_meter_count2();
        }

        /// <summary>
        /// 待处理的异常数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetEx_count()
        {
            return Order_StatisticsService.GetEx_count();
        }

        /// <summary>
        /// 修改订单状态
        /// </summary>
        /// <param name="Ord_id"></param>
        /// <returns></returns>
        [HttpPut("{Ord_id}")]
        public bool UpdateOrder(string Ord_id)
        {
            return Order_StatisticsService.UpdateOrder(Ord_id);
        }
    }
}
